<!--
 * @Author: your name
 * @Date: 2022-03-13 23:09:10
 * @LastEditTime: 2022-03-17 00:41:12
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \算法测试\day0906\原型.html
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text">
    <script>
        
        //所有的引用类型都有一个’_ _ proto_ _'属性(也叫隐式原型，它是一个普通的对象)。
       // console.log({}.prototype);
        function Person(name,age,address){
            this.name = name;
            this.age = age;
            this.address = address;
            this.sayName = function(){
                return this.name;
            }
        }
        let person1 = new Person("a",'18','北京');
        let person2 = new Person("b",'18','上海');
        Person.prototype.setAddress = function(){
            return this.address;
        }
        person1.__proto__.setAge = function(){
            return this.age;
        }
        console.log(person1,person2);
        console.log(person1.constructor === Person && person2.constructor === Person);
        console.log(person1.setAge(),person2.setAge());
        console.log(person1.setAddress(),person2.setAddress());
        console.log(person1.__proto__ == Person.prototype && Person.prototype == Person);
        console.log(Person.prototype.constructor === Person);//true
        console.log(Person.prototype === Person);//false

        
        function name(params) {
            
        }
        console.log(name.prototype.__proto__ == Function); // false

        console.log(Person.prototype.__proto__ === Object.prototype);
        console.log(person1.constructor === Person);
        console.log(Person.prototype.constructor);
    </script>
</body>
</html>